<template>
  <div>
    <div>{{ appStore.token }}</div>
    <div>{{ appStore.tokenWithPrefix }}</div>
    <div>
      <button @click="setToken('456')">同步</button>
    </div>
    <div>
      <button @click="asyncSetToken('789')">异步</button>
    </div>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'
import useAppStore from '@/store/app'

export default defineComponent({
  name: 'App',
  setup() {
    const { setToken, asyncSetToken } = useAppStore
    const appStore = computed(() => {
      const { token, tokenWithPrefix } = useAppStore
      return {
        token,
        tokenWithPrefix
      }
    })
    return {
      appStore,
      setToken,
      asyncSetToken
    }
  }
})
</script>
